<template>
    <svg aria-hidden="true">
        <use :xlink:href="symbolId" />
    </svg>
</template>

<script lang="ts">
    import { defineComponent, computed } from 'vue';

    export default defineComponent({
        name: 'SvgIcon',
        props: {
            prefix: {
                type: String,
                default: 'icon' // 引用SVG文件省去文件名icon前缀
            },
            name: {
                type: String,
                required: true
            }
        },
        setup(props) {
            const symbolId = computed(() => `#${props.prefix}-${props.name}`);
            return {symbolId};
        }

    });

</script>

<style scoped>

</style>